package br.org.ifrr.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;

@Entity
@Table(name = "veic_motorista")
public class Motorista implements Serializable {

	private static final long serialVersionUID = 1L;

	private Long id;
	private String nome;
	private String cnh;
	private Date dataVencimentoCnh;
	private Categoria categoria;
	private String cpf;
	private Date dataAdmissao;
	private String telefone;
	private String email;

	@Id
	@GeneratedValue
	@Column(name = "moto_id")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@NotBlank
	@Size(max = 80)
	@Column(name = "moto_nome", nullable = false, length = 80)
	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	@NotBlank
	@Size(max = 11)
	@Column(name = "moto_cnh", nullable = false, length = 11)
	public String getCnh() {
		return cnh;
	}

	public void setCnh(String cnh) {
		this.cnh = cnh;
	}

	@NotNull
	@Temporal(TemporalType.DATE)
	@Column(name = "moto_data_vencimento_cnh", nullable = false)
	public Date getDataVencimentoCnh() {
		return dataVencimentoCnh;
	}

	public void setDataVencimentoCnh(Date dataVencimentoCnh) {
		this.dataVencimentoCnh = dataVencimentoCnh;
	}

	@NotNull
	@Enumerated(EnumType.STRING)
	@Column(name = "moto_categoria", nullable = false, length = 2)
	public Categoria getCategoria() {
		return categoria;
	}

	public void setCategoria(Categoria categoria) {
		this.categoria = categoria;
	}

	@NotBlank
	@Size(max = 14)
	@Column(name = "moto_cpf", nullable = false, length = 14)
	public String getCpf() {
		return cpf;
	}

	public void setCpf(String cpf) {
		this.cpf = cpf;
	}

	@NotNull
	@Temporal(TemporalType.DATE)
	@Column(name = "moto_data_admissao", nullable = false)
	public Date getDataAdmissao() {
		return dataAdmissao;
	}

	public void setDataAdmissao(Date dataAdmissao) {
		this.dataAdmissao = dataAdmissao;
	}

	@NotBlank
	@Size(max = 14)
	@Column(name = "moto_telefone", nullable = false, length = 14)
	public String getTelefone() {
		return telefone;
	}

	public void setTelefone(String telefone) {
		this.telefone = telefone;
	}

	@Email
	@Size(max = 100)
	@Column(name = "moto_email", length = 100)
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Motorista other = (Motorista) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

}
